//
//  myTabBarViewController.m
//  CustomTabBar
//
//  Created by giantumbrella on 15/5/20.
//  Copyright (c) 2015年 zhaojuan. All rights reserved.
//

#import "myTabBarViewController.h"
#import "HomeViewController.h"
#import "DoorViewController.h"
#import "EvaluationViewController.h"
#import "MyFamilyViewController.h"
#import "SetOutViewController.h"
@interface myTabBarViewController ()

@end

@implementation myTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.view.backgroundColor = [UIColor whiteColor];
    [self setupAllChildViewControllers];
}



-(void)setupAllChildViewControllers{
    
    //1.首页
    HomeViewController *homeView = [[HomeViewController alloc] init];
    [self setupChildViewController:homeView title:@"首页" imageName:@"home@2x" selectedImageName:@"homeSelected@2x"];
    
    //2.测评
    EvaluationViewController *evaluationView = [[EvaluationViewController alloc]init];
    [self setupChildViewController:evaluationView title:@"测评" imageName:@"evaluation@2x" selectedImageName:@"evaluationSelected@2x"];
    
    //3.上门早教
    DoorViewController *establishView = [[DoorViewController alloc]init];
    [self setupChildViewController:establishView title:@"上门早教" imageName:@"door@2x" selectedImageName:@"doorSelected@2x"];
    
    //4.出发
    SetOutViewController *setOutView = [[SetOutViewController alloc] init];
    [self setupChildViewController:setOutView title:@"出发" imageName:@"senOut@2x" selectedImageName:@"senOutSelected@2x"];
    
    //5.我家
    MyFamilyViewController *infomationView = [[MyFamilyViewController alloc] init];
    [self setupChildViewController:infomationView title:@"我家" imageName:@"myFamily@2x" selectedImageName:@"myFamilySelected@2x"];
}

//初始化一个子控件
- (void)setupChildViewController:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{

//1.设置控件属性
    childVC.title = title;
    childVC.tabBarItem.image = [UIImage imageNamed:imageName];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //2.包装一个导航栏
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:childVC];
    

    [self addChildViewController:navi];
}


@end
